package cn.itcast.demo.controller;

import cn.itcast.demo.pojo.User;
import cn.itcast.demo.service.Uservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("hello")
public class HelloController {
    @Autowired
    private Uservice uservice;

    @GetMapping("user/{id}")
    @ResponseBody
    public User queryUserById(@PathVariable("id") Long id) {
        User user = this.uservice.queryUserById(id);
        if (user != null) {

            return user;
        }
        return null;
    }
}
